home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / pdox35sc.zip / BOXDRAW.SC < prev    next >
Text File  |  1991-06-10  |  16KB  |  215 lines

  1. ; ***************************************************************************************
  2. ;                        DRAW A COLORED BOX AT GIVEN COORDINATES
  3.  
  4. ; Copyright 1991   Virginia B. Sauer   All Rights Reserved
  5. ; This program may be copied/modified without charge provided both that this
  6. ; copyright notice is included without change, and that any accompanying
  7. ; documentation includes the notice "Portions of code (c) Copyright 1991,
  8. ; Virginia B. Sauer"
  9. ; ***************************************************************************************
  10.  
  11. ; Although text/endtext commands make it easy to design elaborate screens, such
  12. ; procedures can literally "eat" memory.  This is particularly critical when developing
  13. ; runtime applications:  having no way to determine each user's hardware and software
  14. ; constraints, it is imperative to design each system as efficiently as possible.
  15.  
  16. ; The following generic utility has therefore been designed to automatically draw any
  17. ; type (double, single, or wide-lined) or color box at any given coordinate.
  18. ; Much less memory and disk space is consumed.  Likewise, although slightly more
  19. ; cumbersome at first, this eliminates the necessity of constantly looking up Ascii codes
  20. ; whenever a box must be drawn (particularly in the case of wide lines, which are not
  21. ; available through standard text editors).
  22.  
  23. ; ╔══════════════════════════════════════════════════════════════════════════════════════╗
  24. ; ║                        PARAMETERS  PASSED  TO  THIS  PROCEDURE                       ║
  25. ; ╟───────────┬──────────────────────────────────────────────────────┬───────────────────╢
  26. ; ║  ARGUMENT │                      DESCRIPTION                     │      SAMPLE       ║
  27. ; ╟───────────┼──────────────────────────────────────────────────────┼───────────────────╢
  28. ; ║           │  Whether the box is to be formed with single (│),    │     "Double"      ║
  29. ; ║           │  double (║), or wide (█) lines.                      │                   ║
  30. ; ║ LineType  │                                                      │  (To signify a    ║
  31. ; ║           │  N. B.  Unless this is a variable, it must be        │  box made with    ║
  32. ; ║           │         enclosed in quotes.                          │  double lines)    ║
  33. ; ╟───────────┼──────────────────────────────────────────────────────┼───────────────────╢
  34. ; ║           │                                                      │        63         ║
  35. ; ║           │  The color of the box to be drawn on-screen (based   │                   ║
  36. ; ║ BoxColor  │  on the text attributes in the Paradox manual)       │ (To signify white ║
  37. ; ║           │                                                      │ text on a cyan    ║
  38. ; ║           │                                                      │ background)       ║
  39. ; ╟───────────┼──────────────────────────────────────────────────────┼───────────────────╢
  40. ; ║           │                                                      │        03         ║
  41. ; ║           │                                                      │                   ║
  42. ; ║ StartRow  │  The number of the row of the canvas on which the    │ (To draw the top  ║
  43. ; ║           │  top line of the box is to appear.                   │ line of the box   ║
  44. ; ║           │                                                      │ on the third row  ║
  45. ; ║           │                                                      │ of the canvas)    ║
  46. ; ╟───────────┼──────────────────────────────────────────────────────┼───────────────────╢
  47. ; ║           │                                                      │        11         ║
  48. ; ║           │                                                      │                   ║
  49. ; ║           │  The number of the column of the canvas on which the │ (To place the     ║
  50. ; ║StartColumn│  upper left-hand corner of the box is to appear.     │ upper left-hand   ║
  51. ; ║           │                                                      │ corner of the box ║
  52. ; ║           │                                                      │ on the eleventh   ║
  53. ; ║           │                                                      │ column of the     ║
  54. ; ║           │                                                      │ canvas)           ║
  55. ; ╟───────────┼──────────────────────────────────────────────────────┼───────────────────╢
  56. ; ║           │                                                      │        21         ║
  57. ; ║           │                                                      │                   ║
  58. ; ║           │                                                      │ (To draw the      ║
  59. ; ║   EndRow  │  The number of the row of the canvas on which the    │ bottom line of    ║
  60. ; ║           │  last line of the box is to appear.                  │ the box on the    ║
  61. ; ║           │                                                      │ twenty-first row  ║
  62. ; ║           │                                                      │ of the canvas)    ║
  63. ; ╟───────────┼──────────────────────────────────────────────────────┼───────────────────╢
  64. ; ║           │                                                      │        64         ║
  65. ; ║           │                                                      │                   ║
  66. ; ║ EndColumn │  The number of the column of the canvas on which the │ (To place the     ║
  67. ; ║           │  lower right-hand corner of the box is to appear.    │ lower right-hand  ║
  68. ; ║           │                                                      │ corner of the box ║
  69. ; ║           │                                                      │ on the sixty-     ║
  70. ; ║           │                                                      │ fourth column of  ║
  71. ; ║           │                                                      │ the canvas)       ║
  72. ; ╟───────────┼──────────────────────────────────────────────────────┼───────────────────╢
  73. ; ║           │  If applicable, the first horizontal line drawn      │       19          ║
  74. ; ║           │  inside of the box to help clearly present and       │                   ║
  75. ; ║           │  segregate information.                              │ (To place a hori- ║
  76. ; ║FirstCross │                                                      │ zontal line in-   ║
  77. ; ║           │                                                      │ side of the box   ║
  78. ; ║           │  (If no horizontal lines are to appear within the    │ on row 19 of the  ║
  79. ; ║           │  box, enter "" for this variable)                    │ canvas)           ║
  80. ; ╟───────────┼──────────────────────────────────────────────────────┼───────────────────╢
  81. ; ║           │ If applicable, the next horizontal line drawn inside │        ""         ║
  82. ; ║           │ of the box to help clearly present and segregate     │                   ║
  83. ; ║ NextCross │ information.                                         │ (To signify that  ║
  84. ; ║           │                                                      │ the box does not  ║
  85. ; ║           │ (If the box will contain either no horizontal lines  │ have a second     ║
  86. ; ║           │ or only one such line, enter "" for this variable)   │ second "cross-    ║
  87. ; ║           │                                                      │ line")            ║
  88. ; ╚═══════════╧══════════════════════════════════════════════════════╧═══════════════════╝
  89.  
  90. Proc Draw_Box(LineType,BoxColor,StartRow,StartColumn,Endrow,EndColumn,FirstCross,NextCross)
  91.  
  92.    Private FillNum,     ; Number of horizontal characters to fill in
  93.            X            ; A counter
  94.  
  95.    ; -------------------------------------------------------------------------------------
  96.    ; Determine the number of horizontal characters to fill in between starting and ending
  97.    ; columns
  98.    ; -------------------------------------------------------------------------------------
  99.    Fillnum = (EndColumn - StartColumn -1)
  100.  
  101.    ; -------------------------------------------------------------------------------------
  102.    ; Determine appropriate character for each part of the box (e. g., for each type of
  103.    ; line (single, double, and wide), the upper lefthand corner, upper right hand corner,
  104.    ; lower left hand corner, lower right hand corner, horizontal, and vertical ... As the
  105.    ; wide lines distinguish betwen horizontal "top" and "bottom" characters, both
  106.    ; HorizontalTop and HorizontalBottom are cited.
  107.    ; -------------------------------------------------------------------------------------
  108.    Switch
  109.       Case Upper(LineType) = "SINGLE": UpperLeft     = "\218"   UpperRight       = "\191"
  110.                                        LeftCross     = "\195"   RightCross       = "\180"
  111.                                        LowerLeft     = "\192"   LowerRight       = "\217"
  112.                                        HorizontalTop = "\196"   HorizontalBottom = "\196"
  113.                                        Vertical      = "\179"
  114.       Case Upper(LineType) = "DOUBLE": UpperLeft     = "\201"   UpperRight       = "\187"
  115.                                        LeftCross     = "\204"   RightCross       = "\185"
  116.                                        LowerLeft     = "\200"   LowerRight       = "\188"
  117.                                        HorizontalTop = "\205"   HorizontalBottom = "\205"
  118.                                        Vertical      = "\186"
  119.       Case Upper(LineType) = "WIDE":   UpperLeft     = "\219"   UpperRight       = "\219"
  120.                                        LeftCross     = "\219"   RightCross       = "\219"
  121.                                        LowerLeft     = "\219"   LowerRight       = "\219"
  122.                                        HorizontalTop = "\223"   HorizontalBottom = "\220"
  123.                                        Vertical      = "\219"
  124.    EndSwitch
  125.  
  126.    ; -------------------------------------------------------------------------------------
  127.    ; Specify the color in which to draw the box
  128.    ; -------------------------------------------------------------------------------------
  129.    PaintCanvas Attribute BoxColor StartRow, StartColumn, EndRow, EndColumn  Style Attribute BoxColor
  130.  
  131.    ; -------------------------------------------------------------------------------------
  132.    ; At the designated coordinate, draw the top line of the box
  133.    ; -------------------------------------------------------------------------------------
  134.    @ StartRow, StartColumn ?? UpperLeft, Fill(HorizontalTop,FillNum), UpperRight
  135.  
  136.    ; -------------------------------------------------------------------------------------
  137.    ; Fill in with vertical lines extending from the starting row to the ending row
  138.    ; -------------------------------------------------------------------------------------
  139.    For X From (StartRow + 1) to (EndRow - 1)
  140.       @ X,StartColumn ?? Vertical             ; Vertical lines at the "starting" column
  141.       @ X,EndColumn   ?? Vertical             ; Vertical lines at the "ending" column
  142.    EndFor
  143.  
  144.    ; -------------------------------------------------------------------------------------
  145.    ; If applicable, add intersecting horizontal "crosslines"
  146.    ; -------------------------------------------------------------------------------------
  147.    If not isblank(FirstCross)
  148.       Then @ FirstCross, StartColumn ?? LeftCross, Fill(HorizontalTop,FillNum), RightCross
  149.            If not isblank(NextCross)
  150.               Then @ NextCross,  StartColumn ?? LeftCross, Fill(HorizontalTop,FillNum), RightCross
  151.            Endif
  152.    Endif
  153.    @ EndRow, StartColumn ?? LowerLeft, Fill(HorizontalBottom,FillNum), LowerRight
  154.  
  155. Endproc
  156.  
  157. ; ----------------------------------------------------------------------------------------
  158. ; If desired, an additional horizontal line may be drawn across the canvas (Since this is
  159. ; the exception rather than the rule, it is separated from the "main" box-making
  160. ; procedure to prevent wasting space with seldom- used variables)
  161. ; ----------------------------------------------------------------------------------------
  162.  
  163. Proc Cross_Line(LineType,StartRow,StartColumn,EndColumn)
  164.    Private FillNum,       ; Number of characters to fill in
  165.            X,             ; A counter
  166.            DOUBLESINGLE   ; Single line drawn across double-lined box
  167.    ; -------------------------------------------------------------------------------------
  168.    ; Determine the number of horizontal characters to fill in between starting and ending
  169.    ; columns
  170.    ; -------------------------------------------------------------------------------------
  171.    Fillnum = (EndColumn - StartColumn -1)
  172.  
  173.    ; -------------------------------------------------------------------------------------
  174.    ; Determine appropriate "crossline" character for each part of the box (e. g., for
  175.    ; each type of line (single, double, and wide), the left-hand side character, the
  176.    ; right-hand side character, and the horizontal character)
  177.    ; -------------------------------------------------------------------------------------
  178.    Switch
  179.       Case Upper(LineType) = "SINGLE"       : LeftCross       = "\195"   ; ├
  180.                                               HorizontalCross = "\196"   ; ─
  181.                                               RightCross      = "\180"   ; ┤
  182.       Case Upper(LineType) = "DOUBLE"       : LeftCross       = "\204"   ; ╠
  183.                                               HorizontalCross = "\205"   ; ═
  184.                                               RightCross      = "\185"   ; ╣
  185.       Case Upper(LineType) = "WIDE"         : LeftCross       = "\219"   ; █
  186.                                               HorizontalCross = "\223"   ; ▀
  187.                                               RightCross      = "\219"   ; █
  188.       Case Upper(LineType) = "DOUBLESINGLE" : LeftCross       = "\199"   ; ╟
  189.                                               HorizontalCross = "\196"   ; ─
  190.                                               RightCross      = "\182"   ; ╢
  191.    EndSwitch
  192.  
  193.    ; -------------------------------------------------------------------------------------
  194.    ; At the designated coordinate, draw the specified line
  195.    ; -------------------------------------------------------------------------------------
  196.    @ StartRow, StartColumn ?? LeftCross, Fill(HorizontalCross,Fillnum), RightCross
  197. Endproc
  198.  
  199.  
  200. ; ╔══════════════════════════════════════════════════════════════════════════════════════╗
  201. ; ║                                      EXAMPLE                                         ║
  202. ; ╟──────────────────────────────────────────────────────────────────────────────────────╢
  203. ; ║                                                                                      ║
  204. ; ║        To make a wide-lined white box on a cyan background, beginning at row         ║
  205. ; ║         3, column 11, and ending at row 21, column 64, with no intersecting          ║
  206. ; ║        "cross lines":                                                                ║
  207. ; ║                   Make_Box("Wide", 63, 03, 11, 21, 64, "", "")                       ║
  208. ; ║                                                                                      ║
  209. ; ║        N. B.  This box should be drawn on a black background.  Accordingly,          ║
  210. ; ║               if your canvas is not already black, precede the above with            ║
  211. ; ║               the following command:                                                 ║
  212. ; ║                   Paintcanvas Attribute 00 00, 00, 24, 79 Style attribute 15         ║
  213. ; ║                                                                                      ║
  214. ; ╚══════════════════════════════════════════════════════════════════════════════════════╝
  215.